<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>今天是:</h1>

<script>

    // var date = new Date(1660790379395)
    var date = new Date()  //  获取当前的系统时间
    var time = date.getTime();   //  1970 1 1  到当前时间的毫秒值  1660790379395    1660790638487
    console.log(time)
    // 获取指定时间
    // var date = new Date('2022', '7', '21', '20', '08', '08')
    console.log(date);


    //  设置当前时间的分量
    date.setFullYear(2021)
    date.setMonth(9)
    date.setDate(1)


    // 获取时间分量
    var year = date.getFullYear()
    console.log(year);
    var month = date.getMonth() + 1;
    console.log(month);
    // 月中的天
    var day = date.getDate()
    console.log(day);

    var hours = date.getHours();
    var minutes = date.getMinutes();
    var seconds = date.getSeconds();

    console.log(hours + ":" + minutes + ":" + seconds)

    var weekDay = date.getDay()
    console.log(weekDay);

    var week = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
    var info = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds + " " + week[weekDay]


    document.write(info)   // 定时器  一秒钟写出一次

</script>
</body>
</html>